<?php

declare(strict_types=1);
/**
 * This file is part of MineAdmin.
 *
 * @link     https://www.mineadmin.com
 * @document https://doc.mineadmin.com
 * @contact  root@imoi.cn
 * @license  https://github.com/mineadmin/MineAdmin/blob/master/LICENSE
 */

namespace App\Model;

use Hyperf\Database\Model\Relations\BelongsTo;
use Hyperf\Database\Model\Relations\HasMany;

/**
 * App\Distributor
 *
 * @property int $id
 * @property int $distributor_id 业主id
 * @property string $images 图片集合
 * @property string $name 电站名称
 * @property string $description 简介
 * @property string|null $address 详细地址
 * @property string $lat 经度
 * @property string $lng 纬度
 * @property string $remark 备注
 * @property int $province_code 省份code（预留）
 * @property int $city_code 城市code（预留）
 * @property int $area_code 区域code（预留）
 * @property string $province 省份
 * @property string $city 城市
 * @property string $area 区/县
 * @property int $class_id 分组id
 * @property float $local_fee 电站成本价
 */
class Station extends Model
{
    public bool $timestamps = true;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'stations';


    protected array $guarded = [];

    protected array $casts = [
        'created_at'=>'datetime',
        'updated_at'=>'datetime'
    ];

    /**经销商
     * @return BelongsTo
     */
    public function distributor():BelongsTo{
        return $this->belongsTo(Distributors::class,'distributor_id','id');
    }

    /**
     * 分组
     * @return BelongsTo
     */
    public function stationClass():BelongsTo{
        return $this->belongsTo(StationClass::class,'class_id','id');
    }

/*
 * 设备
 */
    public function device():HasMany{
        return $this->hasMany(Device::class,'station_id','id');
    }


    public function charge() :BelongsTo{
        return $this->belongsTo(ChargeOption::class,'charge_id','id');
    }


    public function order():HasMany{
        return $this->hasMany(Order::class,'station_id','id');
    }


    public function white(){
        return $this->hasMany(White::class,'station_id','id');
    }

}
